package com.leo.offer;

/**
 * 双重检查
 * @author xuexiaolei
 * @version 2018年03月01日
 */
public class T02Singleton03 {
    //一定要注意volatile
    private static volatile T02Singleton03 instance = null;
    private T02Singleton03(){}

    public static T02Singleton03 getInstance() {
        if (instance==null){
            synchronized (T02Singleton03.class){
                if (instance==null){
                    instance = new T02Singleton03();
                }
            }
        }
        return instance;
    }
}
